#include<stdio.h>
#include"proc.h"
#include<time.h>
#include<unistd.h>
#include<stdlib.h>

typedef void (*flush_t)(double total,double current);

const int base = 50;
double total = 2048;
double once = 0.1;



void download(flush_t f)
{
    double current = 0.0;
    while(current < total)
    {
        int r = rand() % base + 1;
        double speed = r * once;
        current +=speed;
        if(current>=total)
            current = total;
        usleep(10000);
        f(total,current);

    }
    printf("\n");    
}


int main()
{
    srand(time(NULL));
    download(flushprocess);
    return 0;
}
